package com.chancingpack.controller;

import com.chancingpack.bean.WxReceiveMessageBean;
import com.chancingpack.bean.WxSendMessageBean;
import com.chancingpack.service.ForselectService;
import com.chancingpack.service.WxReceiveMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * Created by lenovo on 2017/7/14.
 */
@Controller
@RequestMapping("/receive")
public class WxReceiveMessageController {

    @Autowired
    private WxReceiveMessageService wxReceiveMessageService;

    @Autowired
    private ForselectService forselectService;

    @RequestMapping("/insert")
    public ModelAndView index(){
        ModelAndView view = new ModelAndView("logistics/addReceiveMessage");
        List<Map<String, Object>> compaList = forselectService.selectCompa();
        if (compaList != null && compaList.size() > 0) {
            view.addObject("compaList", compaList);
        }
        return view;
    }

    @RequestMapping("/saveInsert")
    public @ResponseBody
    boolean save(WxReceiveMessageBean bean) {
        return wxReceiveMessageService.insertReceiveMessage(bean);
    }

    @RequestMapping("/bigImg")
    public ModelAndView bigImg(@RequestParam(value = "archId") String archId){
        ModelAndView view = new ModelAndView("common/bigImg");
        view.addObject("archId",archId+".jpg");
        return view;
    }
}

